package top.zackyoung.thirdlogin.factory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.zackyoung.thirdlogin.enums.LoginType;
import top.zackyoung.thirdlogin.login.Login;

import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author ZackYoung
 * @version 1.0
 * @description
 * @date 2021/6/5 14:26
 */
@Service
public class FactoryForLogin {
    @Autowired
    Map<String, Login> logins=new ConcurrentHashMap<>(2);

    public Login getLogin(String loginType) {
        Login login = logins.get(loginType);
        if (login == null) {
            throw new RuntimeException("no strategy defined");
        }
        return login;
    }
}
